﻿namespace FFF.Test.DataAccess.Framework.Configuration
{
    using System;
    using System.Collections.Generic;
    using System.Data.Common;
    using System.Text;
    using Microsoft.EntityFrameworkCore;

    /// <summary>
    /// 用户配置程序用什么数据库处理
    /// </summary>
    public static class DbContextOptionsConfigurer
    {
        /// <summary>
        /// 配置adp初始化数据库的方式
        /// </summary>
        /// <param name="dbContextOptions">db配置选项</param>
        /// <param name="connectionString">连接字符串</param>
        public static void Configure(
            DbContextOptionsBuilder<MyDbContext> dbContextOptions,
            string connectionString
            ) => dbContextOptions.UseLazyLoadingProxies(false).UseSqlServer(connectionString);

        /// <summary>
        /// 配置adp初始化数据库的方式
        /// </summary>
        /// <param name="dbContextOptions">db配置选项</param>
        /// <param name="connection">连接对象</param>
        public static void Configure(
            DbContextOptionsBuilder<MyDbContext> dbContextOptions,
            DbConnection connection
        ) => dbContextOptions.UseLazyLoadingProxies(false).UseSqlServer(connection);
    }
}
